<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$item=$this->plugin_setting('setting');
if($_RQ['op']=='list'){

	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'uid'=>$_SESSION['uid']);
	//$fields=array('id','title','start','end','createtime','status','time','name','mobile','people','self','type','num','price');
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_cmspinche_list',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['time']=date('Y-m-d H:i:s',$v['time']);
		if($v['type']==1){
			$v['type2']='拼车';
		}else{
			$v['type2']='带客';
		}	
		if($v['self']){
			$v['self']='拼座';
		}else{
			$v['self']='不拼座';
		}
		if($v['self']){
			$v['self']='拼座';
		}else{
			$v['self']='不拼座';
		}
		if($v['status']==0){
			$v['status']='待审核';
		}elseif($v['status']==1){
			$v['status']='待预定';
		}elseif($v['status']==2){
			$v['status']='已驳回';
		}elseif($v['status']==3){
			$v['status']='已被预定';
		}elseif($v['status']==4){
			$v['status']='已取消';
		}
		
	}
	//print_r($return['list']);exit();
	exi($return);
	}

if($_RQ['op']=='cel'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择项目','error');
	}
	$status=pdo_getcolumn('jy_cmspinche_list',array('id'=>$id),'status');
	if($status==3){
		exi('已预定无法取消','error','myfabu/');
	}
	pdo_update('jy_cmspinche_list',array('status'=>4),array('id'=>$id));
	exi('已取消','','myfabu/');
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择项目','error');
	}
	$status=pdo_get('jy_cmspinche_log',array('pid'=>$id,'status'=>1));
	if($status){
		exi('已预定无法取消','error','myfabu/');
	}
	pdo_delete('jy_cmspinche_list',array('id'=>$id));
	exi('已删除','','myfabu/');
}
?>